<%--
  Created by IntelliJ IDEA.
  User: 联想小鑫
  Date: 2021/11/12
  Time: 15:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-1.8.2.min.js"></script>
    <script src="js/fileupload.js"></script>
    <link rel="stylesheet" href="css/img.css">
</head>
<body>
<form enctype="multipart/form-data">
    地址 : <input type="text" name="haddress" id="haddress"> <br>
    用途: <select name="huse" id="huse">
    <option value="">强选择</option>
    <option value="吃饭">吃饭</option>
    <option value="住宅">住宅</option>
    <option value="别墅">别墅</option>
    <option value="小三">小三</option>
    <option value="正宫">正宫</option>
</select>
    <br>
    面积: <input type="text" name="harea" id="harea"> <br>
    图片: <div class="photoUpLoad" >
    <input type="file"   class="photo" name="photo" accept="image/*"><span class="cross">+</span>
    <img src="" alt="" class="photoEcho">
</div>
    <br>
    房主: <div id="dd"></div>
</form>
<button id="add">添加</button>
</body>
<script>
    $(function () {
        $.ajax({
            url:"findallowner.do",
            dataType:"json",
            type:"post",
            success:function (a) {
                for (let i in a) {
                    $("#dd").append(
                        "<input type=\"checkbox\" name=\"oids\" value='"+a[i].oid+"'>"+a[i].oname
                    )
                }
            }
        })
    })
    $("#add").click(function () {
        var formData=new FormData($("form")[0]);
        $.ajax({
            url:"addhouse.do",
            data:formData,
            dataType:"json",
            type:"post",
            success:function (a) {
                if(a>0){
                    alert("添加成功");
                    location="list.do";
                }
            },processData: false,
            contentType:false,
        })
    })
</script>
</html>
